/*******************************************************************************
   @file    uartStdio.h
   @author  H.M.Shim (elecage@gmail.com)
   @version 
   @date    2013. 8. 12.
   @brief   
  ******************************************************************************
  The MIT License (MIT)

Copyright (c) 2013 <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  ******************************************************************************
  */



/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef UARTSTDIO_H_
#define UARTSTDIO_H_

/* Includes ------------------------------------------------------------------*/

/* Exported typedef -----------------------------------------------------------*/
#define KPU_UART_IRQn 			USART2_IRQn
#define KPU_UART				USART2
#define KUP_UART_CLK			RCC_APB1Periph_USART2
#define KPU_UART_GPIO_TX_CLK 	RCC_AHB1Periph_GPIOA
#define KPU_UART_GPIO_RX_CLK 	RCC_AHB1Periph_GPIOD
#define KPU_UART_TX_PORT		GPIOA
#define KPU_UART_RX_PORT		GPIOD
#define KPU_UART_TX_PIN			GPIO_Pin_2
#define KPU_UART_RX_PIN			GPIO_Pin_6
#define KPU_UART_TX_SOURCE		GPIO_PinSource2
#define KPU_UART_RX_SOURCE		GPIO_PinSource6
/* Exported constants --------------------------------------------------------*/
extern BUFFER uart_buf;
/* Exported macro ------------------------------------------------------------*/

/* Exported variables ------------------------------------------------------- */

/* Exported functions ------------------------------------------------------- */
void uartInit(void);
int32_t uartPutchar(int8_t ch);
int32_t uartPuts(const int8_t * str);
int32_t uartWrite(const int8_t *buf, uint32_t len);
void uartPrintf(const int8_t *str, ...);
int8_t uartGetchar(void);
int32_t uartGets(int8_t *buf, int32_t len);
void UART_NVIC_Config(void);
#endif /* UARTSTDIO_H_ */
